import { lib, game, ui, get, ai, _status } from "../../noname.js";
game.import("extension", function () {
    const eName = '凉拌清心';
    return {
        //VSCode快捷键tip：ctrl+k,ctrl+4
        name: eName, content: function (config, pack) {
            console.log('lbqx_content执行');
            //前置准备
            {
                /**
                 * 函数附加函数代码
                 * @param {Function} func 需附加的代码
                 * @returns {Function} 已被附加后的函数
                 */
                Function.prototype.after = function (func) {
                    let original = this;
                    return function () {
                        let ret = original.apply(this, arguments);
                        func.apply(this.arguments);
                        return ret;
                    }
                }

                /**
                * 加载动画文件
                * @param {string} name skel动画文件路径
                */
                lbqx.loadSpine = function (name) {
                    dcdAnim.loadSpine(name, "skel");
                };

                /**
                * 加载动画文件-跟踪元素
                * @param {string} name skel动画文件路径
                */
                lbqx.loadSpine2 = function (name) {
                    dcdAnim.cap.loadSpine(name, "skel");
                };

                /**
                 * 播放动画
                 * @param {any} show skel动画文件 = { name: 文件路径, action: 动作, speed: 倍速 }
                 * @param {any} cfg 动画参数 = { scale: 缩放, parent: 父元素, x/y: 位置 }
                 */
                lbqx.playSpine = function (show, cfg) {
                    dcdAnim.loadSpine(show.name, "skel", () => {
                        dcdAnim.playSpine(show, cfg);
                    });
                };

                /**
                 * 播放动画-跟踪元素
                 * @param {Element} element 网页元素
                 * @param {any} show skel动画文件 = { name: 文件路径, action: 动作, speed: 倍速 }
                 * @param {any} cfg 动画参数 = { scale: 缩放, parent: 父元素, x/y: 位置 }
                 */
                lbqx.playSpineTo = function (element, show, cfg) {
                    dcdAnim.cap.loadSpine(show.name, "skel", () => {
                        dcdAnim.cap.playSpineTo(element, show.name, cfg);
                    });
                };

                lbqx.game = game;
                lbqx.lib = lib;
                lbqx.ui = ui;
                lbqx.get = get;
                lbqx.ai = ai;
                lbqx._status = _status;
                lbqx.animation = lbqx.preAnimation();
                window.dcdAnim = lbqx.animation;

                ui.updatez = ui.updatez.after(function () {
                    window.documentZoom = game.documentZoom;
                    document.body.style.zoom = game.documentZoom;
                    document.body.style.width = "100%";
                    document.body.style.height = "100%";
                    document.body.style.transform = "";
                    var canvas = document.getElementById("lbqx-canvas");
                    canvas.width = document.body.clientWidth;
                    canvas.height = document.body.clientHeight;
                });
                ui.updatez();


                // // 测试用按钮
                // const spine_test = setInterval(() => {
                //     if (ui.system1 || ui.system2) {
                //         clearInterval(spine_test);
                //         lbqx.test = ui.create.system('spine-test', function () {
                //             lbqx.playSpine({ name: 'screenShow/shoushajisha' });
                //         });
                //     }
                // }, 500);
            }
            //------
            //
            //伤害特效
            if (config.damageShow != 'off') {
                lbqx.damageShow = config.damageShow;
                lib.skill._damageShow = {
                    weaponList: ['dao', 'jian', 'fuzi', 'huoshouji', 'leishouji'],
                    trigger: {
                        player: 'damageBegin4',
                    },
                    filter: function (event) {
                        return event.source;
                    },
                    forced: true,
                    charlotte: true,
                    async content(event, trigger, player) {
                        let n = lbqx.damageShow;
                        if (n == "three") {
                            n = ['dao', 'jian', 'fuzi'].randomGet();
                        }
                        //普通
                        let show = { name: n, action: 'play', };
                        if (trigger.num < 1) return;
                        else if (trigger.num > 1) show.action += '2';
                        //播放
                        show.name = 'damageShow/' + show.name;
                        await lbqx.playSpine(show, { scale: 0.5, parent: player });
                        await game.delay(0.5);
                        //属性
                        if (trigger.nature) {
                            let show2 = { action: 'play', };
                            if (trigger.nature == 'fire') {
                                show2.name = 'huoshouji';
                            } else if (trigger.nature == 'thunder') {
                                show2.name = 'leishouji';
                            } else return;
                            show2.name = 'damageShow/' + show2.name;
                            await lbqx.playSpine(show2, { scale: 0.5, parent: player });
                        }

                    },
                    priority: -Infinity,
                }
                lib.skill._damageShow.weaponList.forEach((name) => {
                    lbqx.loadSpine('damageShow/' + name);
                })
            }
            //------
            //
            //全屏报幕
            if (config.screenShow) {
                lib.skill._killShow = {
                    trigger: {
                        player: 'dieAfter',
                    },
                    silent: true,
                    charlotte: true,
                    forced: true,
                    priority: 9999,
                    filter: function (event, player) {
                        return event.source == game.me;
                    },
                    async content(event, trigger, player) {
                        //记录读取击杀数
                        var sp = trigger.source;
                        if (!sp.killShowNum)
                            sp.killShowNum = 0;
                        let n = ++sp.killShowNum;
                        n = n > 7 ? 7 : n;
                        //动画
                        let show = { name: 'screenShow/shoushajisha', action: 'play' + n, };
                        let cfg = { scale: 0.8 };
                        //音效
                        let file = `${lbqx.ePath}screenShow/` + n + 'k.mp3';
                        let mp3 = new Audio();
                        mp3.src = file;
                        ui.window.appendChild(mp3);
                        //音画同步
                        await lbqx.playSpine(show, cfg);
                        await game.delay(1);
                        mp3.play();
                        //销毁
                        await game.delay(6);
                        mp3?.remove();
                    },
                };
                lbqx.loadSpine('screenShow/shoushajisha');
            }
            //------
            //
            //AI选将
            if (config.AIxuanjiang) {
                lib.choosePlayer = {
                    // 根据模式走不同的方法
                    chooseCharacter: function (target) {
                        var mode = lib.config.mode;
                        if (mode === 'identity' || mode === 'doudizhu') return lib.choosePlayer.chooseCharacterShenFen.call(target);
                        else if (mode === 'guozhan') return lib.choosePlayer.chooseCharacterGuoZhan.call(target);
                    },
                    // 身份模式
                    chooseCharacterShenFen: function () {

                        var next = game.createEvent('chooseCharacter', false);
                        next.target = this;
                        next.player = game.me;
                        next.filter = function (name) {
                            //if (lib.character[name][1] === 'key' || name.indexOf("key") === 0) return false;
                            return true;
                        };
                        next.showConfig = true;
                        next.addPlayer = function (player) {
                            var list = lib.config.mode_config.identity.identity[game.players.length - 3].slice(0);
                            var list2 = lib.config.mode_config.identity.identity[game.players.length - 2].slice(0);
                            for (var i = 0; i < list.length; i++) list2.remove(list[i]);
                            player.identity = list2[0];
                            player.setIdentity('cai');
                        };
                        next.removePlayer = function () {
                            return game.players.randomGet(target, game.zhu);
                        };
                        next.setContent(function () {
                            "step 0"
                            ui.arena.classList.add('choose-character');
                            var i;
                            var list;
                            var list2 = [];
                            var list3 = [];
                            var list4 = [];
                            var identityList;
                            var chosen = lib.config.continue_name || [];
                            game.saveConfig('continue_name');
                            event.chosen = chosen;
                            if (_status.mode === 'zhong') {
                                event.zhongmode = true;
                                identityList = ['zhu', 'zhong', 'mingzhong', 'nei', 'fan', 'fan', 'fan', 'fan'];
                            } else {
                                identityList = lib.config.mode_config.identity.identity[game.players.length - 2].slice(0);
                                if (get.config('double_nei')) {
                                    switch (get.playerNumber()) {
                                        case 8:
                                            identityList.remove('fan');
                                            identityList.push('nei');
                                            break;
                                        case 7:
                                            identityList.remove('zhong');
                                            identityList.push('nei');
                                            break;
                                        case 6:
                                            identityList.remove('fan');
                                            identityList.push('nei');
                                            break;
                                        case 5:
                                            identityList.remove('fan');
                                            identityList.push('nei');
                                            break;
                                        case 4:
                                            identityList.remove('zhong');
                                            identityList.push('nei');
                                            break;
                                        case 3:
                                            identityList.remove('fan');
                                            identityList.push('nei');
                                            break;
                                    }
                                }
                            }
                            event.list = [];
                            identityList.randomSort();
                            if (event.identity) {
                                identityList.remove(event.identity);
                                identityList.unshift(event.identity);
                                if (event.fixedseat) {
                                    var zhuIdentity = (_status.mode == 'zhong') ? 'mingzhong' : 'zhu';
                                    if (zhuIdentity != event.identity) {
                                        identityList.remove(zhuIdentity);
                                        identityList.splice(event.fixedseat, 0, zhuIdentity);
                                    }
                                    delete event.fixedseat;
                                }
                                delete event.identity;
                            } else if (_status.mode != 'zhong' && (!_status.brawl || !_status.brawl.identityShown)) {
                                var ban_identity = [];
                                ban_identity.push(get.config('ban_identity') || 'off');
                                if (ban_identity[0] != 'off') {
                                    ban_identity.push(get.config('ban_identity2') || 'off');
                                    if (ban_identity[1] != 'off') {
                                        ban_identity.push(get.config('ban_identity3') || 'off');
                                    }
                                }
                                ban_identity.remove('off');
                                if (ban_identity.length) {
                                    var identityList2 = identityList.slice(0);
                                    for (var i = 0; i < ban_identity.length; i++) {
                                        while (identityList2.remove(ban_identity[i]));
                                    }
                                    ban_identity = identityList2.randomGet();
                                    identityList.remove(ban_identity);
                                    identityList.splice(game.players.indexOf(target), 0, ban_identity);
                                }
                            }
                            if (get.config('special_identity') && !event.zhongmode && game.players.length == 8) {
                                for (var i = 0; i < game.players.length; i++) {
                                    delete game.players[i].special_identity;
                                }
                                event.special_identity = [];
                                var zhongs = game.filterPlayer(function (current) {
                                    return current.identity == 'zhong';
                                });
                                var fans = game.filterPlayer(function (current) {
                                    return current.identity == 'fan';
                                });
                                if (fans.length >= 1) {
                                    fans.randomRemove().special_identity = 'identity_zeishou';
                                    event.special_identity.push('identity_zeishou');
                                }
                                if (zhongs.length > 1) {
                                    zhongs.randomRemove().special_identity = 'identity_dajiang';
                                    zhongs.randomRemove().special_identity = 'identity_junshi';
                                    event.special_identity.push('identity_dajiang');
                                    event.special_identity.push('identity_junshi');
                                } else if (zhongs.length == 1) {
                                    if (Math.random() < 0.5) {
                                        zhongs.randomRemove().special_identity = 'identity_dajiang';
                                        event.special_identity.push('identity_dajiang');
                                    } else {
                                        zhongs.randomRemove().special_identity = 'identity_junshi';
                                        event.special_identity.push('identity_junshi');
                                    }
                                }
                            }
                            if (!game.zhu) game.zhu = target;
                            else {
                                game.zhu.setIdentity();
                                game.zhu.identityShown = true;
                                game.zhu.isZhu = (game.zhu.identity == 'zhu');
                                game.zhu.node.identity.classList.remove('guessing');

                            }
                            //选将框分配
                            for (i in lib.characterReplace) {
                                var ix = lib.characterReplace[i];
                                for (var j = 0; j < ix.length; j++) {
                                    if (chosen.includes(ix[j]) || lib.filter.characterDisabled(ix[j])) ix.splice(j--, 1);
                                }
                                if (ix.length) {
                                    event.list.push(i);
                                    list4.addArray(ix);
                                    var bool = false;
                                    for (var j of ix) {
                                        if (lib.character[j][4] && lib.character[j][4].includes('zhu')) {
                                            bool = true;
                                            break;
                                        }
                                    }
                                    (bool ? list2 : list3).push(i);
                                }
                            }
                            for (i in lib.character) {
                                if (list4.includes(i)) continue;
                                if (chosen.includes(i)) continue;
                                if (lib.filter.characterDisabled(i)) continue;

                                if (typeof event.filter === 'function' && event.filter(i) === false) continue;

                                event.list.push(i);
                                list4.push(i);
                                if (lib.character[i][4] && lib.character[i][4].includes('zhu')) {
                                    list2.push(i);
                                } else {
                                    list3.push(i);
                                }
                            }
                            list2.sort(lib.sort.character);
                            event.list.randomSort();
                            _status.characterlist = list4.slice(0).randomSort();
                            list3.randomSort();
                            if (_status.brawl && _status.brawl.chooseCharacterFilter) {
                                _status.brawl.chooseCharacterFilter(event.list, list2, list3);
                            }
                            var num = get.config('choice_' + target.identity);
                            if (event.zhongmode) {
                                num = 6;
                                if (target.identity == 'zhu' || target.identity == 'nei' || target.identity == 'mingzhong') {
                                    num = 8;
                                }
                            }
                            if (target === game.zhu && lib.config.mode !== "doudizhu") {
                                list = list2.concat(list3.slice(0, num));
                            } else {
                                list = list3.slice(0, 8);
                            }
                            // }
                            delete event.swapnochoose;
                            var dialog;
                            if (event.swapnodialog) {
                                dialog = ui.dialog;
                                event.swapnodialog(dialog, list);
                                delete event.swapnodialog;
                            } else {
                                var str = '选择角色';
                                if (_status.brawl && _status.brawl.chooseCharacterStr) {
                                    str = _status.brawl.chooseCharacterStr;
                                }
                                dialog = ui.create.dialog(str, 'hidden', [list, 'characterx']);
                            }

                            var createSearchInput = function (dialog) {
                                var div = ui.create.div(dialog.content, 1, {
                                    display: 'block',
                                });
                                var input = ui.create.node('input', div);
                                var select = ui.create.node('select', div);
                                var options = [{
                                    text: '武将id',
                                    value: 'id',
                                    defaultSelected: false,
                                }, {
                                    text: '武将名称',
                                    value: 'name',
                                    defaultSelected: true,
                                }];
                                options.forEach(value => {
                                    var option = new Option(value.text, value.value, value.defaultSelected);
                                    option.selected = value.defaultSelected;
                                    select.appendChild(option);
                                });
                                select.onchange = function () {
                                    input.placeholder = this.value === 'id' ? '按武将ID搜索' : '按武将名称搜索';
                                }
                                input.placeholder = '按武将名称搜索';
                                var toggleButtons = function () {
                                    var mode = select.value;
                                    var inputValue = this.value;
                                    var buttons = Array.from(dialog.querySelectorAll('.button'))
                                    buttons.forEach(value => {
                                        var link = value.link;
                                        var buttonName = link;
                                        if (mode === 'name') buttonName = get.translation(link);
                                        if (this.value === '') return value.classList.remove('nodisplay');
                                        value.classList.toggle('nodisplay', buttonName.indexOf(inputValue) === -1);
                                    });
                                    return true;
                                }
                                input.onkeydown = function (event) {
                                    event && event.stopPropagation();
                                    if (event.keyCode === 13) this.oninput(event);
                                };
                                input.oninput = event => toggleButtons.call(input) && event.stopPropagation();
                                dialog.searchInput = input;
                                dialog.select = select;
                            }

                            createSearchInput(dialog);

                            dialog.searchInput.disabled = true;
                            dialog.searchInput.placeholder = '点击【自由选将】搜索';
                            dialog.select.disabled = true;

                            if (target.special_identity) {
                                dialog.setCaption('选择角色（' + get.translation(target.special_identity) + '）');
                                target.node.identity.firstChild.innerHTML = get.translation(target.special_identity + '_bg');
                            } else {
                                dialog.setCaption('选择角色');
                                //target.setIdentity();
                            }
                            if (lib.onfree) {
                                lib.onfree.push(function () {
                                    event.dialogxx = ui.create.characterDialog('heightset', target);
                                });
                            } else {
                                event.dialogxx = ui.create.characterDialog('heightset', target);
                            }

                            /*补充所有武将*/
                            var charactersKey = Object.keys(lib.character).removeArray(event.dialogxx.buttons.map(value => value.link)).filter(value => {
                                var character = lib.character[value];
                                if (!character || !character[4]) return false;
                                return !character[4].includes('unseen')
                            });
                            if (!event.chosen.length) {
                                game.me.chooseButton(event.dialogxx, true).set('onfree', true).selectButton = function () {
                                    if ((_status.brawl && _status.brawl.doubleCharacter) || (target == game.zhu && _status.mode == 'online')) return 2;
                                    return get.config('double_character') ? 2 : 1
                                };
                            } else {
                                lib.init.onfree();
                            }

                            var buttons1 = ui.create.buttons(charactersKey, 'character', event.dialogxx.querySelector(".buttons"));
                            event.dialogxx.buttons = event.dialogxx.buttons.concat(buttons1);
                            const getCapt = function (str) {
                                var capt;
                                if (str.indexOf('_') == -1) {
                                    capt = str[0];
                                } else {
                                    capt = str[str.lastIndexOf('_') + 1];
                                }
                                capt = capt.toLowerCase();
                                if (!/[a-z]/i.test(capt)) {
                                    capt = '自定义';
                                }
                                return capt;
                            }
                            buttons1.forEach(item => {
                                item.group = lib.character[item.link][1];
                                item.capt = getCapt(item.link);
                                item.classList.add('nodisplay')
                            })

                            "step 1"
                            if (_status.mode == 'online') event.cardPile = target.storage.doudizhu_cardPile;
                            if (ui.cheat) {
                                ui.cheat.close();
                                delete ui.cheat;
                            }
                            if (ui.cheat2) {
                                ui.cheat2.close();
                                delete ui.cheat2;
                            }
                            var chooseGroup = false;
                            if (event.chosen.length) {
                                if (lib.character[event.chosen[0]][1] == 'shen' && !lib.character[event.chosen[0]][4].includes('hiddenSkill')) {
                                    chooseGroup = true;
                                }
                            } else if (event.modchosen) {
                                if (event.modchosen[0] == 'random') event.modchosen[0] = result.buttons[0].link;
                                else event.modchosen[1] = result.buttons[0].link;
                            } else if (result.buttons.length == 2) {
                                event.choosed = [result.buttons[0].link, result.buttons[1].link];
                                game.addRecentCharacter(result.buttons[0].link, result.buttons[1].link);
                                if (lib.character[event.choosed[0]][1] == 'shen' && !lib.character[event.choosed[0]][4].includes('hiddenSkill')) {
                                    chooseGroup = true;
                                }
                            } else {
                                event.choosed = [result.buttons[0].link];
                                if (lib.character[event.choosed[0]][1] == 'shen' && !lib.character[event.choosed[0]][4].includes('hiddenSkill')) {
                                    chooseGroup = true;
                                }
                                game.addRecentCharacter(result.buttons[0].link);
                            }
                            if (get.config('choose_group') && chooseGroup) {
                                var list = lib.group.slice(0);
                                list.remove('shen');
                                game.me.chooseControl(list).prompt = '请选择神武将的势力';
                            }
                            "step 2"
                            event.group = result.control || false;
                            if (event.chosen.length) {
                                lib.element.player.uninit.call(target);
                                lib.element.player.init.call(target, event.chosen[0], event.chosen[1]);
                            } else if (event.modchosen) {
                                lib.element.player.uninit.call(target);
                                lib.element.player.init.call(target, event.modchosen[0], event.modchosen[1]);
                            } else if (event.choosed.length == 2) {
                                lib.element.player.uninit.call(target);
                                lib.element.player.init.call(target, event.choosed[0], event.choosed[1]);
                            } else {
                                lib.element.player.uninit.call(target);
                                lib.element.player.init.call(target, event.choosed[0]);
                            }
                            event.list.remove(get.sourceCharacter(target.name1));
                            event.list.remove(get.sourceCharacter(target.name2));
                            if (target == game.zhu && _status.mode != 'purple') {
                                if (game.players.length > 4 || get.mode() == 'doudizhu') {
                                    target.hp++;
                                    target.maxHp++;
                                    target.update();
                                }
                                if (get.mode() == 'identity') {
                                    var enhance_zhu = false;
                                    if (_status.connectMode) {
                                        enhance_zhu = (_status.mode != 'zhong' && _status.mode != 'purple' && lib.configOL.enhance_zhu && get.population('fan') >= 3);
                                    } else {
                                        enhance_zhu = (_status.mode != 'zhong' && _status.mode != 'purple' && get.config('enhance_zhu') && get.population('fan') >= 3);
                                    }
                                    if (enhance_zhu) {
                                        var skill;
                                        switch (game.zhu.name) {
                                            case 'key_yuri':
                                                skill = 'buqu';
                                                break;
                                            case 'liubei':
                                                skill = 'jizhen';
                                                break;
                                            case 'dongzhuo':
                                                skill = 'hengzheng';
                                                break;
                                            case 'sunquan':
                                                skill = 'batu';
                                                break;
                                            case 'sp_zhangjiao':
                                                skill = 'tiangong';
                                                break;
                                            case 'liushan':
                                                skill = 'shengxi';
                                                break;
                                            case 'sunce':
                                                skill = 'ciqiu';
                                                break;
                                            case 're_sunben':
                                                skill = 'ciqiu';
                                                break;
                                            case 'yuanshao':
                                                skill = 'geju';
                                                break;
                                            case 're_caocao':
                                                skill = 'dangping';
                                                break;
                                            case 'caopi':
                                                skill = 'junxing';
                                                break;
                                            case 'liuxie':
                                                skill = 'moukui';
                                                break;
                                            default:
                                                skill = 'tianming';
                                                break;
                                        }
                                        game.broadcastAll(function (player, skill) {
                                            target.addSkill(skill);
                                            target.storage.enhance_zhu = skill;
                                        }, game.zhu, skill);
                                    }
                                }
                                if (get.mode() == 'doudizhu') {
                                    if (['normal', 'huanle', 'kaihei'].includes(_status.mode)) {
                                        var skill = ['feiyang', 'bahu'];
                                        game.broadcastAll(function (player, skill) {
                                            target.addSkill(skill);
                                        }, game.zhu, skill);
                                    }
                                    if (_status.mode == 'binglin') {
                                        var skill = game.zhuSkill;
                                        game.broadcastAll(function (player, skill) {
                                            target.addSkill(skill);
                                        }, game.zhu, skill);
                                    }
                                }
                            } else {
                                if (_status.mode == 'binglin') {
                                    var skill = ['binglin_shaxue', 'binglin_neihong'];
                                    game.broadcastAll(function (player, skill) {
                                        target.addSkill(skill);
                                    }, target, skill);
                                }
                            }
                            if (_status.mode == 'online') {
                                game.zhu.hp = 4;
                                game.zhu.maxHp = 4;
                                game.zhu.update();
                                target.storage.doudizhu_cardPile = event.cardPile;
                                target.markSkill('doudizhu_cardPile');
                            }
                            if (_status.mode == 'purple') {
                                if (target == game.rZhu || target == game.bZhu) {
                                    target.hp++;
                                    target.maxHp++;
                                    target.update();
                                }
                            }

                            "step 3"
                            if (event.group) {
                                target.group = event.group;
                                target.node.name.dataset.nature = get.groupnature(target.group);
                                target.update();
                            }
                            for (var i = 0; i < game.players.length; i++) {
                                _status.characterlist.remove(game.players[i].name);
                                _status.characterlist.remove(game.players[i].name1);
                                _status.characterlist.remove(game.players[i].name2);
                            }
                            "step 4"
                            setTimeout(function () {
                                ui.arena.classList.remove('choose-character');
                            }, 500);

                            if (event.special_identity) {
                                for (var i = 0; i < event.special_identity.length; i++) {
                                    game.zhu.addSkill(event.special_identity[i]);
                                }
                            }
                        });
                    },
                    // 国战
                    chooseCharacterGuoZhan: function () {
                        var next = game.createEvent('chooseCharacter', false);
                        next.showConfig = true;
                        next.addPlayer = true;
                        next.target = this;
                        next.player = game.me;
                        next.ai = function (player, list, back) {
                            if (_status.brawl && _status.brawl.chooseCharacterAi) {
                                if (_status.brawl.chooseCharacterAi(player, list, back) !== false) {
                                    return;
                                }
                            }
                            var filterChoice = function (name1, name2) {
                                if (get.is.double(name1)) return false;
                                var group1 = lib.character[name1][1];
                                var group2 = lib.character[name2][1];
                                if (group1 == 'ye') return group2 != 'ye';
                                var double = get.is.double(name2, true);
                                if (double) return double.includes(group1);
                                return group1 == group2;
                            };
                            for (var i = 0; i < list.length - 1; i++) {
                                for (var j = i + 1; j < list.length; j++) {
                                    if (filterChoice(list[i], list[j]) || filterChoice(list[j], list[i])) {
                                        var mainx = list[i];
                                        var vicex = list[j];
                                        if (!filterChoice(mainx, vicex) || (filterChoice(vicex, mainx) && get.guozhanReverse(mainx, vicex))) {
                                            mainx = list[j];
                                            vicex = list[i];
                                        }
                                        player.init(mainx, vicex, false);
                                        if (back) {
                                            list.remove(player.name1);
                                            list.remove(player.name2);
                                            for (var i = 0; i < list.length; i++) {
                                                back.push(list[i]);
                                            }
                                        }
                                        return;
                                    }
                                }
                            }
                        }
                        next.setContent(function () {
                            "step 0"
                            ui.arena.classList.add('choose-character');
                            var addSetting = function (dialog) {
                                dialog.add('选择座位').classList.add('add-setting');
                                var seats = document.createElement('table');
                                seats.classList.add('add-setting');
                                seats.style.margin = '0';
                                seats.style.width = '100%';
                                seats.style.position = 'relative';
                                for (var i = 1; i <= game.players.length; i++) {
                                    var td = ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode');
                                    td.innerHTML = '<span>' + get.cnNumber(i, true) + '</span>';
                                    td.link = i - 1;
                                    seats.appendChild(td);
                                    td.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', function () {
                                        if (_status.dragged) return;
                                        if (_status.justdragged) return;
                                        if (_status.cheat_seat) {
                                            _status.cheat_seat.classList.remove('bluebg');
                                            if (_status.cheat_seat == this) {
                                                delete _status.cheat_seat;
                                                return;
                                            }
                                        }
                                        this.classList.add('bluebg');
                                        _status.cheat_seat = this;
                                    });
                                }
                                dialog.content.appendChild(seats);
                                if (game.me == game.zhu) {
                                    seats.previousSibling.style.display = 'none';
                                    seats.style.display = 'none';
                                }
                                dialog.add(ui.create.div('.placeholder.add-setting'));
                                dialog.add(ui.create.div('.placeholder.add-setting'));
                                if (get.is.phoneLayout()) dialog.add(ui.create.div('.placeholder.add-setting'));
                            };
                            var removeSetting = function () {
                                var dialog = _status.event.dialog;
                                if (dialog) {
                                    dialog.style.height = '';
                                    delete dialog._scrollset;
                                    var list = Array.from(dialog.querySelectorAll('.add-setting'));
                                    while (list.length) {
                                        list.shift().remove();
                                    }
                                    ui.update();
                                }
                            };
                            event.addSetting = addSetting;
                            event.removeSetting = removeSetting;
                            var chosen = lib.config.continue_name || [];
                            game.saveConfig('continue_name');
                            event.chosen = chosen;
                            var i;
                            event.list = [];
                            for (i in lib.character) {
                                if (i.indexOf('gz_shibing') == 0) continue;

                                if (chosen.includes(i)) continue;
                                if (lib.filter.characterDisabled(i)) continue;
                                if (get.config('onlyguozhan')) {
                                    if (!lib.characterPack.mode_guozhan[i]) continue;
                                    if (get.is.jun(i)) continue;
                                }
                                if (lib.character[i][4].includes('hiddenSkill')) continue;
                                if (lib.character[i][2] == 3 || lib.character[i][2] == 4 || lib.character[i][2] == 5)
                                    event.list.push(i);

                            }
                            _status.characterlist = event.list.slice(0);
                            _status.yeidentity = [];
                            if (_status.brawl && _status.brawl.chooseCharacterFilter) {
                                event.list = _status.brawl.chooseCharacterFilter(event.list);
                            }
                            event.list.randomSort();

                            var list;
                            if (_status.brawl && _status.brawl.chooseCharacter) {
                                list = _status.brawl.chooseCharacter(event.list, game.me);
                            } else {
                                list = game.getCharacterChoice(event.list, parseInt(get.config('choice_num')));
                            }
                            if (_status.auto) {
                                event.ai(target, list);
                                lib.init.onfree();
                            } else if (chosen.length) {
                                game.me.init(chosen[0], chosen[1], false);
                                lib.init.onfree();
                            } else {
                                event.dialogxx = ui.create.characterDialog('heightset', function (i) {
                                    if (i.indexOf('gz_shibing') == 0) return true;
                                    if (get.config('onlyguozhan')) {
                                        if (!lib.characterPack.mode_guozhan[i]) return true;
                                        if (get.is.jun(i)) return true;
                                    }
                                }, get.config('onlyguozhanexpand') ? 'expandall' : undefined, get.config('onlyguozhan') ? 'onlypack:mode_guozhan' : undefined, target);
                                var dialog = ui.create.dialog('选择角色', 'hidden', [list, 'character']);
                                if (!_status.brawl || !_status.brawl.noAddSetting) {
                                    if (get.config('change_identity')) {
                                        addSetting(dialog);
                                    }
                                }
                                var next = game.me.chooseButton(event.dialogxx, true, 2).set('onfree', true);
                                next.filterButton = function (button) {
                                    if (ui.dialog.buttons.length <= 10) {
                                        for (var i = 0; i < ui.dialog.buttons.length; i++) {
                                            if (ui.dialog.buttons[i] != button) {
                                                if (lib.element.player.perfectPair.call({
                                                    name1: button.link, name2: ui.dialog.buttons[i].link
                                                })) {
                                                    button.classList.add('glow2');
                                                }
                                            }
                                        }
                                    }
                                    if (lib.character[button.link][4].includes('hiddenSkill')) return false;
                                    if (ui.selected.buttons.length == 0) {
                                        if (get.is.double(button.link)) return false;
                                        if (lib.character[button.link][1] == 'ye') return true;
                                        for (var i = 0; i < ui.dialog.buttons.length; i++) {
                                            var double = get.is.double(ui.dialog.buttons[i].link, true);
                                            if (ui.dialog.buttons[i] != button && (lib.character[button.link][1] == lib.character[ui.dialog.buttons[i].link][1] || double && double.includes(lib.character[button.link][1]))) {
                                                return true;
                                            }
                                        }
                                        return false;
                                    }
                                    if (!lib.character[button.link] || lib.character[button.link][1] == 'ye') return false;
                                    if (get.is.double(ui.selected.buttons[0].link)) return false;
                                    if (lib.character[ui.selected.buttons[0].link][1] == 'ye') return true;
                                    if (get.is.double(button.link)) return get.is.double(button.link, true).includes(lib.character[ui.selected.buttons[0].link][1]);
                                    return (lib.character[button.link][1] == lib.character[ui.selected.buttons[0].link][1]);
                                };
                                next.switchToAuto = function () {
                                    event.ai(target, list);
                                    ui.arena.classList.remove('selecting');
                                };
                            }
                            "step 1"
                            if (ui.cheat) {
                                ui.cheat.close();
                                delete ui.cheat;
                            }
                            if (ui.cheat2) {
                                ui.cheat2.close();
                                delete ui.cheat2;
                            }
                            if (result.buttons) {
                                lib.element.player.init.call(target, result.buttons[0].link, result.buttons[1].link, false);
                                game.addRecentCharacter(result.buttons[0].link, result.buttons[1].link);
                            }
                            target.setIdentity(target.group);
                            target.classList.add('unseen');
                            target.classList.add('unseen2');
                            if (target != game.me) {
                                target.node.identity.firstChild.innerHTML = '猜';
                                target.node.identity.dataset.color = 'unknown';
                                target.node.identity.classList.add('guessing');
                            }
                            target.hiddenSkills = lib.character[target.name1][3].slice(0);
                            var hiddenSkills2 = lib.character[target.name2][3];
                            for (var j = 0; j < hiddenSkills2.length; j++) {
                                target.hiddenSkills.add(hiddenSkills2[j]);
                            }
                            for (var j = 0; j < target.hiddenSkills.length; j++) {
                                if (!lib.skill[target.hiddenSkills[j]]) {
                                    target.hiddenSkills.splice(j--, 1);
                                }
                            }
                            target.group = 'unknown';
                            target.sex = 'unknown';
                            target.name1 = target.name;
                            target.name = 'unknown';
                            target.identity = 'unknown';
                            target.node.name.show();
                            target.node.name2.show();
                            target._group = lib.character[target.name1][1];
                            for (var j = 0; j < target.hiddenSkills.length; j++) {
                                target.addSkillTrigger(target.hiddenSkills[j], true);
                            }
                            setTimeout(function () {
                                ui.arena.classList.remove('choose-character');
                            }, 500);
                        });
                    },
                };
                lib.skill._AIxuanjiang = {
                    trigger: {
                        global: 'gameStart',
                        player: 'enterGame',
                    },
                    forced: true,
                    popup: false,
                    silent: true,
                    priority: 523,
                    firstDo: true,
                    filter: function (event, player) {
                        return player === game.me && ['identity', 'guozhan', 'doudizhu'].includes(lib.config.mode);
                    },
                    content: function () {
                        'step 0'
                        player.chooseTarget([1, 1], get.prompt('AI选将'), "请选择一名角色并替换其武将牌", lib.filter.all).set('ai', function (target) {
                            return 0;
                        });
                        'step 1'
                        if (result.bool) {
                            event.target = result.targets[0];
                            lib.choosePlayer.chooseCharacter(event.target);
                        } else event.finish();
                        'step 2'
                        event.goto(0);
                    },
                };
            }
            //------
            //
            //手杀MVP
            if (config.shoushaMVP) {
                "use strict;"
                lib.onover.push(resultbool => {
                    var 全场最佳 = function () {
                        if (_status.showShoushaMvp) return false;
                        _status.showShoushaMvp = true;
                        setTimeout(item => {
                            var dialog = Array.from(ui.arena.querySelectorAll(".dialog"));
                            dialog.forEach(value => value.hide());
                            var players = game.players.slice(0);
                            game.players = game.players.concat(game.dead);
                            if (!_status.showShouSha局势) {
                                game.players.forEach(value => {
                                    if (game.dead.includes(value)) {
                                        value.局势分数 -= 20;
                                    }
                                    value.getEnemies().forEach(current => {
                                        if (game.dead.includes(current) || current.isDead()) {
                                            value.局势分数 += 2;
                                        }
                                    })
                                    value.getFriends().forEach(current => {
                                        if (current.isDead() || game.dead.includes(current))
                                            value.局势分数 -= 2;
                                    })
                                })
                            }
                            _status.showShouSha局势 = true;
                            game.players = players;
                            /**
                             * 冒泡排序
                             * @param arr
                             * @param len
                             */
                            var sort = function (arr) {
                                var temp, len = arr.length;
                                var i, j;
                                for (i = 0; i < len - 1; i++) /* 外循环为排序趟数，len个数进行len-1趟 */
                                    for (j = 0; j < len - 1 - i; j++) { /* 内循环为每趟比较的次数，第i趟比较len-i次 */
                                        if (arr[j].mvpCount > arr[j + 1].mvpCount) { /* 相邻元素比较，若逆序则交换（升序为左大于右，降序反之） */
                                            temp = arr[j];
                                            arr[j] = arr[j + 1];
                                            arr[j + 1] = temp;
                                        }
                                    }
                                return arr;
                            }
                            var sorts = sort(game.players.concat(game.dead)).reverse();
                            var player = sorts[0];
                            var popuperContainer = ui.create.div('.popup-container', { background: "rgb(0,0,0,.7)" }, ui.window);
                            popuperContainer.addEventListener('click', event => {
                                event.stopPropagation();
                                popuperContainer.delete(200);
                                dialog.forEach(value => value.show());
                                _status.showShoushaMvp = false;
                            });
                            var skills = player.skills.filter(value => lib.skill[value].audio);
                            skills.length && game.trySkillAudio(skills.randomGet(), player, true);
                            var qycontainer = ui.create.div('.qy-mvp-container', popuperContainer);

                            var backgroundRight = ui.create.div('.qy-mvp-piaodai-right', qycontainer);
                            var container = ui.create.div('.qy-center-container', qycontainer);
                            var backgroundLeft = ui.create.div('.qy-mvp-piaodai-left', qycontainer);

                            var avatarbox = ui.create.div('.qy-mvp-avatarbox', container);
                            if (navigator.userAgent.match(/(Android|iPhone|SymbianOS|Windows Phone|iPad|iPod)/i) !== null) {
                                avatarbox.css({
                                    height: '120%',
                                    top: '-4%',
                                });
                            }
                            var avatarborder = ui.create.div('.qy-mvp-avatarborder', avatarbox);
                            avatarborder.dataset.name = get.translation(player.name);
                            avatarborder.setBackgroundImage(`${lbqx.ePath}mvp/images/border_${player.group}1.png`);
                            var image = new Image();
                            image.src = `${lbqx.ePath}mvp/images/border_${player.group}1.png`;
                            image.onerror = function () {
                                avatarborder.setBackgroundImage(`${lbqx.ePath}mvp/images/border_qun1.png`);
                            }
                            var avatar = ui.create.div('.qy-mvp-avatar', avatarbox);
                            //mvp读取大图
                            var playername = get.name(player);
                            avatar.style.backgroundImage = player.node.avatar.style.backgroundImage;

                            avatar.style['top'] = '23.6%';
                            avatar.style['height'] = '54%';
                            var qyInfo = ui.create.div('.qy-mvp-qyInfo', container);
                            ui.create.div('.qy-mvp-title', qyInfo);
                            var qycenter = ui.create.div('.qy-mvp-center', qyInfo);
                            var qyIcon = ui.create.div('.qy-mvp-icon', qycenter);
                            var qyPlayerInfo = ui.create.div('.qy-player-info', qycenter);
                            ui.create.div(qyPlayerInfo, '.qy-mvp-name-title', '玩家昵称');
                            //增加本人图标开始修改
                            var nickname = ui.create.div('.qy-mvp-player-nickname', qyPlayerInfo, player === game.me ? lib.config.connect_nickname : get.translation(player.name));
                            if (game.me === player) ui.create.node('img', nickname).src = lib.assetURL + `${lbqx.ePath}mvp/images/mvp_me_tag.png`;
                            //增加本人图标修改结束
                            ui.create.div(qyPlayerInfo, '.qy-mvp-name-title', `技术分：${player.mvpCount || 0}`);
                            var qyScoreInfo = ui.create.div('.qy-mvp-scoreInfo', qyInfo);
                            var table = ui.create.node('table', qyScoreInfo, { width: "100%" });
                            var list = ['攻击分数', '治疗分数', '辅助分数', '局势分数', '惩罚扣分'];
                            list.forEach(value => {
                                var tr = ui.create.node('tr', table);
                                tr.style.colo = 'rgb(234, 138, 76)';
                                var td = ui.create.node('td', tr, value);
                                var num = (player[value] || 0);
                                var num2 = (sorts[1][value]);
                                td = ui.create.node('td', tr).innerHTML = num + (num - num2 >= 30 ? '(遥遥领先)' : '');
                            })
                        }, 2000)//结算时延迟出现时间
                    }
                    ui.create.control("全场最佳", 全场最佳);
                    全场最佳();
                });
                ['攻击分数', '治疗分数', '辅助分数', '惩罚扣分'].forEach(value => {
                    HTMLDivElement.prototype[value] = 0;
                });
                HTMLDivElement.prototype.局势分数 = 100;
                Object.defineProperty(HTMLDivElement.prototype, 'mvpCount', {
                    get: function () {
                        return this.攻击分数 + this.治疗分数 + this.辅助分数 + this.局势分数 - this.惩罚扣分;
                    },
                    set: function () {
                    },
                });
                lib.skill['_qy-mvp-effect1'] = {
                    trigger: {
                        player: 'useCard',
                        source: 'damageSource',
                    },
                    direct: true,
                    forced: true,
                    firstDo: true,
                    silent: true,
                    popup: false,
                    filter: function (event, player, name) {
                        if (name === 'useCard') {
                            if (!event.card) return false;
                            if (get.tag({ name: event.card.name }, 'damage')) return true;
                            if (event.card.name === 'wuxie') return true;
                            if (get.info(event.card).toself || get.type(event.card) !== 'trick') return false;
                            if (get.info(event.card).selectTarget === -1 || get.info(event.card).selectTarget > 1) return true;
                            return false;
                        }
                        if (event.player == event.source) return false;
                        if (event.source.identity == 'nei') return true;
                        return get.attitude(event.source, event.player) < 0;
                    },
                    content: function () {
                        if (event.triggername === 'damageSource') {
                            if (get.attitude(trigger.source, trigger.player) < 0 || trigger.source.identity == 'nei') trigger.num > 5 ? trigger.source.攻击分数 += 15 : trigger.source.攻击分数 += 3 * trigger.num;
                        } else if (trigger.card) {
                            if (get.tag({ name: trigger.card.name }, 'damage'))
                                player.攻击分数 += 2
                            if (trigger.card.name === 'wuxie')
                                player.辅助分数 += 2;
                            if ((get.info(trigger.card).selectTarget === -1 || get.info(trigger.card).selectTarget > 1) && (!get.info(trigger.card).toself && get.type(trigger.card) === 'trick'))
                                player.辅助分数 += 1;
                        }
                    }
                }
                lib.skill['_qy-mvp-effect2'] = {
                    trigger: { player: ['gainEnd', 'discardEnd'] },
                    direct: true,
                    forced: true,
                    firstDo: true,
                    silent: true,
                    popup: false,
                    filter: function (event, player, name) {
                        if (name === 'gainEnd') {
                            if (!event.source || event.source == player) return false;
                            //var evt=event.getl(event.source);
                            //if(!evt&&!evt.cards2&&evt.cards2.length===0) return false;
                            if (!event.cards || event.cards.length == 0) return false;
                            if (event.source.identity == 'nei') return true;
                            return event.player.getEnemies().includes(event.source);
                        }
                        if (name === 'discardEnd') {
                            if (!event.source || event.source == player) return false;
                            //var evt=event.getl(event.source);
                            //if(!evt&&!evt.cards2&&evt.cards2.length===0) return false;
                            if (!event.cards || event.cards.length == 0) return false;
                            if (event.source.identity == 'nei') return true;
                            return event.player.getEnemies().includes(event.source);
                        }
                    },
                    content: function () {
                        if (event.triggername == 'gainEnd') trigger.player.辅助分数 += 1 * trigger.cards.length;
                        if (event.triggername == 'discardEnd') trigger.source.辅助分数 += 1 * trigger.cards.length;
                    },
                }
                lib.skill['_qy-mvp-effect3'] = {
                    trigger: { player: 'recoverEnd' },
                    direct: true,
                    forced: true,
                    firstDo: true,
                    silent: true,
                    popup: false,
                    filter: function (event, player) {
                        if (!event.source) return false;
                        if (event.source.identity == 'nei') return true;
                        return event.player.getFriends().includes(event.source) || event.player == event.source;
                    },
                    content: function () {
                        trigger.num > 5 ? trigger.source.治疗分数 += 10 : trigger.source.治疗分数 += 2 * trigger.num;
                    },
                }
                lib.skill['_qy-mvp-effect4'] = {
                    trigger: { source: 'dieBegin' },
                    direct: true,
                    forced: true,
                    firstDo: true,
                    silent: true,
                    popup: false,
                    filter: function (event, player) {
                        return (event.source);
                    },
                    content: function () {
                        if (trigger.player.getFriends().includes(trigger.source)) {
                            trigger.source.惩罚扣分 += 5;
                            if (trigger.source.identity == 'nei' && trigger.player.identity != 'zhu') {
                                trigger.source.惩罚扣分 -= 5;
                                trigger.source.攻击分数 += 3;
                            }
                        }
                        if (trigger.player.getEnemies().includes(trigger.source)) {
                            trigger.source.攻击分数 += 3;
                        }
                    },
                }
                lib.skill['_qy-mvp-effect5'] = {
                    trigger: {
                        player: "enterGame",
                        global: ["roundStart", "gameStart"],
                    },
                    direct: true,
                    forced: true,
                    priority: Infinity,
                    firstDo: true,
                    silent: true,
                    popup: false,
                    content: function () {
                        if (!_status._qy_mvp_effect5) {
                            try {
                                var changValue = false;
                                var input = ui.commandnode.link.querySelector("input");
                                var Opt = Object.getOwnPropertyDescriptor(input.__proto__, "value");
                                Object.defineProperty(input, 'value', {
                                    get: function () {
                                        var value = (Opt.get && Opt.get.call(this)) || '';
                                        if (value === '') changValue = false;
                                        else changValue = true
                                        return value;
                                    },
                                    set: function (v) {
                                        Opt.set.call(this, v);
                                    },
                                    configurable: true,
                                })
                                Array.from(ui.commandnode.parentElement.parentElement.querySelectorAll(".menubutton.round.highlight")).forEach(value => {
                                    value.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', function (event) {
                                        if ('作' === value.innerText && this.classList.includes('glowing')) {
                                            game.me.惩罚扣分 += 3;
                                        } else if ('执' === value.innerText && changValue) {
                                            game.me.惩罚扣分 += 3;
                                        }
                                    }, true);
                                })
                            } catch (e) {
                                console.error("作弊加载失败：", e)
                            }
                            _status._qy_mvp_effect5 = true;
                        }
                    },
                };
                //样式
                lib.init.css(lib.assetURL + `${lbqx.ePath}mvp`, 'mvp');
            }
            //------
            //
            //势力显示
            if (config.groupShow) {
                lib.skill._groupShow = {
                    trigger: {
                        global: "gameStart",
                    },
                    forced: true,
                    priority: 999,
                    firstDo: true,
                    content: function () {
                        var color = 'LightGray';
                        switch (player.group) {
                            case 'wei': color = 'LightBlue'; break;
                            case 'shu': color = 'orange'; break;
                            case 'wu': color = 'greenyellow'; break;
                            case 'jin': color = 'Plum'; break;
                        }
                        player.node.name.insertAdjacentHTML('afterbegin', '<span style="'
                            + 'color: ' + color + ';">' + lib.translate[player.group] + '</span>');
                    },
                }
            }
            //------
            //
            //菜单美化
            if (config.menuBeautification) {
                lib.init.css(lbqx.ePath + 'menuBeautification/', 'menu');
            }
            //------
            //
            //更多武将数选项
            if (config.moreConfigNumber) {
                let item = {
                    '5': '5', '6': '6', '7': '7', '8': '8', '9': '9',
                    '10': '10', '11': '11', '12': '12', '13': '13', '14': '14',
                    '15': '15', '16': '16', '17': '17', '18': '18', '19': '19',
                    '20': '20', '21': '21', '22': '22', '23': '23', '24': '24',
                    '25': '25', '26': '26', '27': '27', '28': '28', '29': '29',
                    '30': '30', '31': '31', '32': '32', '33': '33', '34': '34',
                    '35': '35', '36': '36', '37': '37', '38': '38', '39': '39',
                };
                lib.configMenu.view.config.recent_character_number.item = item;
                item['0'] = "∞";
                lib.configMenu.view.config.showMax_character_number.item = item;
            }
            //------
            //避免延时锦囊
            if (config.dontDelay) {
                lib.skill._dontDelay = {
                    mod: {
                        targetEnabled(card, player, target, now) {
                            if (get.type(card) == "delay" && target == game.me && player != target) {
                                return false;
                            }
                        },
                    },
                    "_priority": 0,
                }
            }
            //------
            //动皮特效
            if (config.dynamicSkinShow) {
                lbqx.dynamicSkinShowCD = true;
                /**
                * 动皮特效
                * @param {string} playerName 武将id（动皮文件夹名）
                * @param {string} action 动画动作名[默认'GongJi']
                */
                function dynamicSkinShow(playerName, action = 'GongJi') {
                    console.log("dynamicSkinShow:" + playerName);
                    lbqx.playSpine(
                        { name: "dynamicSkin/" + playerName + "/XingXiang", action: action, speed: action == 'GongJi' ? 2 : 1 },
                        { scale: 0.5, x: window.innerWidth / 4 }
                    );
                    lbqx.dynamicSkinShowCD = false;
                    setTimeout(() => { lbqx.dynamicSkinShowCD = true }, 1000);
                }
                lbqx.dynamicSkinShow = dynamicSkinShow;
                lib.skill._chuChangShow = {
                    silent: true,
                    charlotte: true,
                    forced: true,
                    priority: 9999,
                    trigger: {
                        global: "phaseBefore",
                        player: "enterGame",
                    },
                    filter(event, player) {
                        return player == game.me && lbqx.dynamicSkinShowCD && (event.name != "phase" || game.phaseNumber == 0);
                    },
                    async content(event, trigger, player) {
                        lbqx.dynamicSkinShow(player.name, "ChuChang");
                    },
                    "_priority": 0,
                }
                lib.skill._gongJiShow = {
                    silent: true,
                    charlotte: true,
                    forced: true,
                    priority: 9999,
                    trigger: {
                        player: "useCard",
                    },
                    filter(event, player) {
                        return event.card.name == "sha" && lbqx.dynamicSkinShowCD;
                    },
                    async content(event, trigger, player) {
                        lbqx.dynamicSkinShow(player.name);
                    },
                    "_priority": 0,
                }
            }
            //------
            //阶段提示
            if (config.phaseTip) {
                /**
                * 显示阶段提示图片
                * @param {string} phase 阶段/图片文件名
                * @param {number} time 显示时长
                */
                lbqx.phaseTip = function (phase, time) {
                    if (!phase) return false;
                    console.log("phaseTip:" + phase);
                    var pos = [18, 65, 8, 4.4];
                    if (!time || (isNaN(time) && time !== true)) time = 3;
                    lbqx.removePhaseTip();

                    var handcards = document.getElementById('handcards1');
                    if (!handcards) return false;
                    var img = document.createElement('img');
                    handcards.appendChild(img);
                    img.src = lbqx.ePath + "phaseTip/" + phase + ".png";
                    img.style = "right: 0px; height:20%; object-fit:contain; top:-25%; position: absolute; z-index: -1; pointer-events:none;"
                    lbqx.phaseTipDiv = img;

                    if (time === true) return true;
                    setTimeout(function () {
                        if (lbqx.phaseTipDiv) {
                            lbqx.phaseTipDiv.remove();
                            delete lbqx.phaseTipDiv;
                        }
                    }, time * 1000);

                    return true;
                };
                lbqx.removePhaseTip = function () {
                    if (!lbqx.phaseTipDiv) return;
                    var outdiv = lbqx.phaseTipDiv;
                    delete lbqx.phaseTipDiv;
                    outdiv.remove();
                }
                lib.onover.push(() => { lbqx.removePhaseTip(); });
                //等待响应
                lib.skill._phaseTip_ddxyA = {
                    trigger: {
                        player: ["chooseToRespondBegin"],
                    },
                    silent: true,
                    direct: true,
                    filter: function (event, player) {
                        return player == game.me && _status.auto == false;
                    },
                    content: function () {
                        lbqx.phaseTip_ddxy = true;
                        lbqx.phaseTip("ddxy", 10);
                    },
                };
                //成为杀的目标开始
                lib.skill._phaseTip_ddxyB = {
                    trigger: {
                        target: "shaBegin",
                    },
                    silent: true,
                    filter: function (event, player) {
                        return game.me == event.target;
                    },
                    charlotte: true,
                    forced: true,
                    content: function () {
                        lbqx.phaseTip_ddxy = true;
                        lbqx.phaseTip("ddxy", true);
                    },
                };
                lib.skill._phaseTip_ddxyC = {
                    trigger: {
                        player: ["useCardToBegin", "phaseJudge"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        if (event.card.storage && event.card.storage.nowuxie) return false;
                        var card = event.card;
                        var info = get.info(card);
                        if (info.wuxieable === false) return false;
                        if (event.name != "phaseJudge") {
                            if (event.getParent().nowuxie) return false;
                            if (!event.target) {
                                if (info.wuxieable) return true;
                                return false;
                            }
                            if (event.player.hasSkillTag("playernowuxie", false, event.card)) return false;
                            if (get.type(event.card) != "trick" && !info.wuxieable) return false;
                        }
                        return player == game.me && _status.auto == false;
                    },
                    charlotte: true,
                    forced: true,
                    content: function () {
                        lbqx.phaseTip_ddxy = true;
                        lbqx.phaseTip("ddxy", true);
                    },
                };
                //使用或打出闪后
                lib.skill._phaseTip_shiyongshanD = {
                    forced: true,
                    charlotte: true,
                    trigger: {
                        player: ["useCard", "respondAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && event.card.name == "shan";
                    },
                    content: function () {
                        lbqx.phaseTip_ddxy = true;
                        lbqx.removePhaseTip();
                        if (lbqx.phaseTipPhase) {
                            lbqx.phaseTip(lbqx.phaseTipPhase, true);
                        }
                    },
                };
                //等待响应及游戏结束
                lib.skill._phaseTip_ddxyE = {
                    trigger: {
                        player: ["chooseToRespondEnd", "useCardEnd", "phaseJudgeEnd", "respondSha", "shanBegin"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        if (!lbqx.phaseTip_ddxy) return false;
                        return player == game.me && _status.auto == false;
                    },
                    direct: true,
                    content: function () {
                        lbqx.phaseTip_ddxy = false;
                        lbqx.removePhaseTip();
                        if (lbqx.phaseTipPhase) {
                            lbqx.phaseTip(lbqx.phaseTipPhase, true);
                        }
                    },
                };
                //对方正在思考
                lib.skill._phaseTip_dfsk = {
                    trigger: {
                        global: ["phaseBegin", "phaseEnd", "phaseJudgeBegin", "phaseDrawBegin", "phaseUseBegin", "phaseDiscardBegin"],
                    },
                    silent: true,
                    charlotte: true,
                    forced: true,
                    filter: function (event, player) {
                        //剩余人数两人时
                        if (game.players.length == 2 && _status.currentPhase != game.me) return true;
                    },
                    content: function () {
                        lbqx.phaseTip("dfsk", true);
                    },
                };
                //死亡或回合结束消失
                lib.skill._phaseTip_wjsw = {
                    trigger: {
                        global: ["phaseEnd", "useCardAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return _status.currentPhase != game.me && player != game.me;
                    },
                    forced: true,
                    charlotte: true,
                    content: function () {
                        lbqx.removePhaseTip();
                    },
                };
                lib.skill._phaseTip_swxs = {
                    trigger: {
                        global: ["dieAfter"],
                    },
                    silent: true,
                    forced: true,
                    charlotte: true,
                    filter: function (event, player) {
                        return player == game.me && _status.auto == false;
                    },
                    content: function () {
                        lbqx.removePhaseTip();
                    },
                };
                //回合开始
                lib.skill._phaseTip_hhks = {
                    trigger: {
                        player: ["phaseBegin"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("hhks", true);
                        lbqx.phaseTipPhase = "hhks";
                    },
                };
                //准备阶段
                lib.skill._phaseTip_zbjdb = {
                    trigger: {
                        player: ["phaseZhunbeiBefore"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("zbjd", true);
                        lbqx.phaseTipPhase = "zbjd";
                    },
                };
                lib.skill._phaseTip_zbjde = {
                    trigger: {
                        player: ["phaseZhunbeiAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "zbjd") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
                //判定阶段
                lib.skill._phaseTip_pdjdb = {
                    trigger: {
                        player: ["phaseJudgeBefore"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("pdjd", true);
                        lbqx.phaseTipPhase = "pdjd";
                    },
                };
                lib.skill._phaseTip_pdjde = {
                    trigger: {
                        player: ["phaseJudgeAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "pdjd") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
                //摸牌阶段
                lib.skill._phaseTip_mpjdb = {
                    trigger: {
                        player: ["phaseDrawBefore"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("mpjd", true);
                        lbqx.phaseTipPhase = "mpjd";
                    },
                };
                lib.skill._phaseTip_mpjde = {
                    trigger: {
                        player: ["phaseDrawAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "mpjd") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
                //出牌阶段
                lib.skill._phaseTip_cpjdb = {
                    trigger: {
                        player: ["phaseUseBefore"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("cpjd", true);
                        lbqx.phaseTipPhase = "cpjd";
                    },
                };
                lib.skill._phaseTip_cpjde = {
                    trigger: {
                        player: ["phaseUseAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "cpjd") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
                //弃牌阶段
                lib.skill._phaseTip_qpjdb = {
                    trigger: {
                        player: ["phaseDiscardBefore"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("qpjd", true);
                        lbqx.phaseTipPhase = "qpjd";
                    },
                };
                lib.skill._phaseTip_qpjde = {
                    trigger: {
                        player: ["phaseDiscardAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "qpjd") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
                //结束阶段
                lib.skill._phaseTip_jsjdb = {
                    trigger: {
                        player: ["phaseJieshuBefore"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("jsjd", true);
                        lbqx.phaseTipPhase = "jsjd";
                    },
                };
                lib.skill._phaseTip_jsjde = {
                    trigger: {
                        player: ["phaseJieshuAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "jsjd") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
                //回合结束
                lib.skill._phaseTip_hhjsb = {
                    trigger: {
                        player: ["phaseEnd"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: Infinity,
                    firstDo: true,
                    content: function () {
                        lbqx.phaseTip("hhjs", true);
                        lbqx.phaseTipPhase = "hhjs";
                    },
                };
                lib.skill._phaseTip_hhjse = {
                    trigger: {
                        player: ["phaseAfter"],
                    },
                    silent: true,
                    filter: function (event, player) {
                        return player == game.me && _status.currentPhase == player;
                    },
                    charlotte: true,
                    ruleSkill: true,
                    direct: true,
                    priority: -Infinity,
                    lastDo: true,
                    content: function () {
                        if (lbqx.phaseTipPhase && lbqx.phaseTipPhase == "hhjs") {
                            lbqx.removePhaseTip();
                            delete lbqx.phaseTipPhase;
                        }
                    },
                };
            }
            //------
            //卡牌特效
            if (config.cardShow) {
                //使用卡牌
                lib.skill._cardShow = {
                    silent: true,
                    charlotte: true,
                    forced: true,
                    priority: 9999,
                    cardList: [
                        "effect_leisha",
                        "effect_huosha",
                        "effect_hongsha",
                        "effect_heisha",
                        "effect_shan",
                        "effect_tao",
                        "effect_tiesuolianhuan",
                        "effect_jiu",
                        "effect_huogong",
                        "effect_wuzhongshengyou",
                        "effect_wuxiekeji",
                        "SSZBB_DDZ_eff_juedou",
                        "effect_nanmanruqin",
                        "effect_wanjianqifa",
                        "effect_wugufengdeng",
                        "effect_taoyuanjieyi",
                        "effect_taoyuanjieyi",
                        "effect_shunshouqianyang",
                        "effect_guohechaiqiao",
                        "effect_yuanjiaojingong",
                        "effect_zhijizhibi",
                        "effect_zhulutianxia"
                    ],
                    trigger: {
                        player: "useCard",
                    },
                    filter(event, player) {
                        return event.card && event.cards[0]?.clone;
                    },
                    async content(event, trigger, player) {
                        var card = trigger.card,
                            name = card.name,
                            nature = card.nature,
                            n = '',
                            cfg = {};
                        switch (name) {
                            case "sha":
                                switch (nature) {
                                    case "thunder":
                                        n = "effect_leisha";
                                        break;
                                    case "fire":
                                        n = "effect_huosha";
                                        break;
                                    default:
                                        if (get.color(card) == "red") {
                                            n = "effect_hongsha";
                                        } else {
                                            n = "effect_heisha";
                                        }
                                        break;
                                }
                                break;
                            case "shan":
                                n = "effect_shan";
                                break;
                            case "tao":
                                n = "effect_tao"; cfg = { scale: 0.9 };
                                break;
                            case "tiesuo":
                                n = "effect_tiesuolianhuan"; cfg = { scale: 0.9 };
                                break;
                            case "jiu":
                                n = "effect_jiu"; cfg = { y: [-30, 0.5] };
                                break;
                            case "huogong":
                                n = "effect_huogong"; cfg = { x: [8, 0.5], scale: 0.5 }
                                break;
                            case "wuzhong":
                                n = "effect_wuzhongshengyou";
                                break;
                            case "wuxie":
                                n = "effect_wuxiekeji"; cfg = { y: [10, 0.5], scale: 0.9 };
                                break;
                            case "juedou":// 从标记补充挖过来的
                                n = "SSZBB_DDZ_eff_juedou"; cfg = { scale: 0.5 };
                                break;
                            case "nanman":
                                n = "effect_nanmanruqin"; cfg = { scale: 0.45 };
                                break;
                            case "wanjian":
                                n = "effect_wanjianqifa"; cfg = { scale: 0.78 };
                                break;
                            case "wugu":
                                n = "effect_wugufengdeng"; cfg = { y: [10, 0.5] };
                                break;
                            case "taoyuan":
                                n = "effect_taoyuanjieyi"; cfg = { y: [10, 0.5] };
                                break;
                            case "shunshou":
                                n = "effect_shunshouqianyang";
                                break;
                            case "guohe":
                                n = "effect_guohechaiqiao"; cfg = { y: [10, 0.5] };
                                break;
                            case "yuanjiao":
                                n = "effect_yuanjiaojingong";
                                break;
                            case "zhibi":
                                n = "effect_zhijizhibi";
                                break;
                            case "zhulu_card":
                                n = "effect_zhulutianxia";
                                break;
                            default: return;
                        }
                        await lbqx.playSpineTo(trigger.cards[0].clone, { name: 'cardShow/' + n }, cfg);
                    },
                };
                lib.skill._cardShow.cardList.forEach((name) => {
                    lbqx.loadSpine2('cardShow/' + name);
                });
                //装备技能
                lib.skill._cardShow2 = {
                    silent: true,
                    charlotte: true,
                    forced: true,
                    priority: 9999,
                    equipList: {
                        bagua_skill: {
                            skill: "bagua_skill",
                            name: "effect_baguazhen",
                            scale: 0.6,
                        },
                        baiyin_skill: {
                            skill: "baiyin_skill",
                            name: "effect_baiyinshizi",
                            scale: 0.5,
                        },
                        bazhen_bagua: {
                            skill: "bazhen_bagua",
                            name: "effect_baguazhen",
                            scale: 0.6,
                        },
                        cixiong_skill: {
                            skill: "cixiong_skill",
                            name: "effect_cixiongshuanggujian",
                            scale: 0.5,
                        },
                        fangtian_skill: {
                            skill: "fangtian_skill",
                            name: "effect_fangtianhuaji",
                            scale: 0.7,
                        },
                        guanshi_skill: {
                            skill: "guanshi_skill",
                            name: "effect_guanshifu",
                            scale: 0.7,
                        },
                        guding_skill: {
                            skill: "guding_skill",
                            name: "effect_gudingdao",
                            scale: 0.6,
                            x: [0, 0.4],
                            y: [0, 0.05],
                        },
                        hanbing_skill: {
                            skill: "hanbing_skill",
                            name: "effect_hanbingjian",
                            scale: 0.5,
                        },
                        linglong_bagua: {
                            skill: "linglong_bagua",
                            name: "effect_baguazhen",
                            scale: 0.5,
                        },
                        qilin_skill: {
                            skill: "qilin_skill",
                            name: "effect_qilingong",
                            scale: 0.5,
                        },
                        qinggang_skill: {
                            skill: "qinggang_skill",
                            name: "effect_qinggangjian",
                            scale: 0.7,
                        },
                        qinglong_skill: {
                            skill: "qinglong_skill",
                            name: "effect_qinglongyanyuedao",
                            scale: 0.6,
                        },
                        renwang_skill: {
                            skill: "renwang_skill",
                            name: "effect_renwangdun",
                            scale: 0.5,
                        },
                        tengjia1: {
                            skill: "tengjia1",
                            name: "effect_tengjiafangyu",
                            scale: 0.6,
                        },
                        tengjia2: {
                            skill: "tengjia2",
                            name: "effect_tengjiaranshao",
                            scale: 0.6,
                        },
                        tengjia3: {
                            skill: "tengjia3",
                            name: "effect_tengjiafangyu",
                            scale: 0.6,
                        },
                        zhangba_skill: {
                            skill: "zhangba_skill",
                            name: "effect_zhangbashemao",
                            scale: 0.7,
                        },
                        zhuge_skill: {
                            skill: "zhuge_skill",
                            name: "effect_zhugeliannu",
                            scale: 0.5,
                        },
                        zhuque_skill: {
                            skill: "zhuque_skill",
                            name: "effect_zhuqueyushan",
                            scale: 0.6,
                        },
                    },
                    trigger: {
                        global: ["useSkill", "logSkillBegin"],
                    },
                    filter(event, player) {
                        var sn = event.skill;
                        return this.equipList[sn] && !event.cardShow
                    },
                    async content(event, trigger, player) {
                        trigger.cardShow = true;
                        var sn = trigger.skill;
                        var cfg = lib.skill._cardShow2.equipList[sn];
                        cfg.parent = trigger.player;
                        await lbqx.playSpine({ name: 'cardShow/' + cfg.name }, cfg);
                    },
                };
                Object.values(lib.skill._cardShow2.equipList).forEach((cfg) => {
                    lbqx.loadSpine('cardShow/' + cfg.name);
                });
                //延时锦囊效果
                lib.skill._cardShow3 = {
                    silent: true,
                    charlotte: true,
                    forced: true,
                    priority: 9999,
                    delayList: {
                        lebu: {
                            skill: "lebu",
                            name: "effect_lebusishu",
                            scale: 0.7
                        },
                        bingliang: {
                            skill: "bingliang",
                            name: "effect_bingliangcunduan",
                            scale: 0.7,
                        },
                        shandian: {
                            skill: "shandian",
                            name: "effect_shandian",
                            scale: 0.7,
                        }
                    },
                    trigger: {
                        player: "judgeEnd",
                    },
                    filter(event, player) {
                        var cn = event.cardname;
                        return this.delayList[cn] && !event.cardShow && !event.result.bool
                    },
                    async content(event, trigger, player) {
                        trigger.cardShow = true;
                        var cn = trigger.cardname;
                        var cfg = lib.skill._cardShow3.delayList[cn];
                        cfg.parent = trigger.player;
                        await lbqx.playSpine({ name: 'cardShow/' + cfg.name }, cfg);
                    },
                }
                Object.values(lib.skill._cardShow3.delayList).forEach((cfg) => {
                    lbqx.loadSpine('cardShow/' + cfg.name);
                });
            }
            //------
        }, precontent: function (config) {
            console.log('lbqx_precontent执行');
            //前置准备工作
            {
                //全局接口
                window.lbqx = {
                    eName: eName,
                    ePath: lib.assetURL + "extension/" + eName + "/",
                };

                //导入方法
                {
                    var version = lib.extensionPack[eName].version;
                    lbqx.js = function (path) {
                        if (!path) return console.error("path");

                        const script = document.createElement("script");
                        script.onload = function () {
                            this.remove();
                        };
                        script.onerror = function () {
                            this.remove();
                            console.error(`${this.src}not found`);
                        };
                        script.src = `${path}?v=${version}`;
                        document.head.appendChild(script);
                        return script;
                    };
                    lbqx.css = function (path) {
                        if (!path) return console.error("path");
                        const link = document.createElement("link");
                        link.rel = "stylesheet";
                        link.href = `${path}?v=${version}`;
                        document.head.appendChild(link);
                        return link;
                    };
                }

                if (!window.spine)
                    lbqx.js(lbqx.ePath + 'spine.js');
                lbqx.js(lbqx.ePath + 'animation.js');
                lbqx.css(lbqx.ePath + 'animation.css');

                lbqx.gameEventLog = function (b) {
                    console.log('lbqx.gameEventLog:' + b);
                    if (!lbqx.GameEventBackup)
                        lbqx.GameEventBackup = lib.element.GameEvent.prototype.constructor;
                    if (b) {
                        lib.element.GameEvent = class GameEvent extends lib.element.GameEvent {
                            constructor(...args) {
                                const result = new lbqx.GameEventBackup(...args);
                                try {
                                    var str = '游戏事件：' + result.name;
                                    if (result.name == 'trigger')
                                        str += '[' + result.manager.eventStack.at(-1).triggername + ']'
                                    console.log(str);
                                } catch (error) {
                                    console.error('游戏事件日志错误: ' + error);
                                }
                                return result;
                            }
                        }
                    } else {
                        lib.element.GameEvent = lbqx.GameEventBackup;
                    }
                }
                lbqx.gameEventLog(config.gameEventLog);
            }
            //------
            //
            //指示线特效
            if (config.lineShow != 'off') {
                //新方法
                game.zsPlayLineAnimation = function (name, node, fake, points) {
                    var gudaxuan = {
                        "time": 1200,
                        "position": "screen",
                        "width": "256px",
                        "height": "128px",
                        "backgroundSize": "100% 100%",
                        "opacity": 1,
                        "show": "none",
                        "fade": true,
                        "pause": false,
                        "rate_zhen": 18,
                        "jump_zhen": false,
                        "qianzhui": "",
                        "liang": false,
                        "isLine": true,
                        "cycle": true,
                        "style": {},
                        "skills": [],
                        "cards": [],
                        "forbid": false,
                        "image": "jianqilinexy"
                    };
                    var animation = gudaxuan;
                    animation["image"] = name;
                    if (lib.config.zsGuideTime) {
                        animation["time"] = parseInt(lib.config.zsGuideTime);
                    }
                    if (animation == undefined) return;
                    if (animation.time <= 100000) {
                        if (animation.pause != false && !_status.paused2 && !_status.nopause) {
                            _status.zhx_onAnimationPause = true;
                            game.pause2();
                        };
                        if (_status.zhx_onAnimation == undefined) _status.zhx_onAnimation = 0;
                        _status.zhx_onAnimation++;
                    };
                    var src;
                    if (animation.image != undefined) src = 'extension/' + eName + '/pointer/' + animation.image + '?' + new Date().getTime();
                    var finish = function () {
                        var animationID;
                        var timeoutID;
                        var interval;
                        var div = ui.create.div();
                        if (fake == true) {
                            ui.window.appendChild(div);
                        } else {
                            if (node == undefined || node == false) {
                                ui.window.appendChild(div);
                            } else {
                                node.appendChild(div);
                            };
                        };
                        if (animation.style != undefined) {
                            for (var i in animation.style) {
                                if (i == 'innerHTML') continue;
                                div.style[i] = animation.style[i];
                            };
                        };
                        var judgeStyle = function (style) {
                            if (animation.style == undefined) return false;
                            if (animation.style != undefined && animation.style[style] != undefined) return true;
                            return false;
                        };
                        if (judgeStyle('innerHTML')) div.innerHTML = animation.style.innerHTML;
                        if (judgeStyle('width') == false) div.style.width = animation.width;
                        if (judgeStyle('height') == false) div.style.height = animation.height;
                        if (judgeStyle('backgroundSize') == false && judgeStyle('background-size') == false) div.style.backgroundSize = animation.backgroundSize;
                        if (judgeStyle('opacity') == false) div.style.opacity = animation.opacity;
                        if (judgeStyle('zIndex') == false && judgeStyle('z-index') == false) div.style.zIndex = 1001;
                        if (judgeStyle('borderRadius') == false && judgeStyle('border-radius') == false) div.style.borderRadius = '5px';
                        if (judgeStyle('pointer-events') == false && judgeStyle('pointerEvents') == false) div.style['pointer-events'] = 'none';
                        if (src != undefined) {
                            if (animation.image.indexOf('.') != -1) {
                                div.setBackgroundImage(src);
                            } else {
                                var type_frame1 = 0;
                                var type_frame = '.jpg';
                                var num_frame = 1;
                                type_frame = '.png';
                                num_frame = 8;
                                var folder_frame = lib.assetURL + 'extension/' + eName + '/pointer/' + animation.image + '/';
                                var div1 = ui.create.div();
                                div1.style.height = '100%';
                                div1.style.width = '100%';
                                div1.style.top = '0px';
                                div1.style.left = '0px';
                                div1.style.opacity = '0.7';
                                div.appendChild(div1);
                                var canvas = document.createElement("canvas");
                                canvas.width = div1.offsetWidth;
                                canvas.height = div1.offsetHeight;
                                div1.appendChild(canvas);
                                var context = canvas.getContext("2d");
                                var start;
                                var imgs = [];
                                var imgs_num = 0;
                                for (var i = 0; i < num_frame; i++) {
                                    var img = new Image();
                                    img.src = folder_frame + (animation.qianzhui == undefined ? '' : animation.qianzhui) +
                                        (animation.liang == true ? (i < 10 ? '0' + i : i) : i) + type_frame;
                                    if (i >= num_frame - 1) img.zhx_final = true;
                                    img.onload = function () {
                                        imgs.push(this);
                                        if (this.zhx_final == true) start();
                                    };
                                    img.onerror = function () {
                                        if (this.zhx_final == true) start();
                                    };
                                };
                                start = function () {
                                    var play = function () {
                                        if (imgs_num >= imgs.length) return;
                                        var img = imgs[imgs_num];
                                        context.clearRect(0, 0, img.width, img.height);
                                        context.drawImage(img, 0, 0, img.width, img.height, 0, 0, div1.offsetWidth, div1.offsetHeight);
                                        imgs_num++;
                                        if (animation.jump_zhen == true && imgs[imgs_num + 1] != undefined) imgs.remove(imgs_num + 1);
                                        if (imgs_num >= imgs.length) {
                                            if (animation.cycle == true) {
                                                imgs_num = 0;
                                            } else {
                                                if (interval != undefined) clearInterval(interval);
                                                if (timeoutID != undefined) clearTimeout(timeoutID);
                                                if (animationID != undefined) cancelAnimationFrame(animationID);
                                            };
                                        };
                                    };
                                    interval = setInterval(play, animation.rate_zhen == undefined ? 45 : (1000 / animation.rate_zhen));
                                };


                            };
                        };
                        if (points == undefined) {
                            if (fake == true) {
                                div.style.top = (top - div.offsetHeight / 2) + 'px';
                                div.style.left = (left - div.offsetWidth / 2) + 'px';
                            } else {
                                if (judgeStyle('top') == false) div.style.top = 'calc(50% - ' + (div.offsetHeight / 2) + 'px)';
                                if (judgeStyle('left') == false) div.style.left = 'calc(50% - ' + (div.offsetWidth / 2) + 'px)';
                            };
                        } else {
                            div.style.top = (points[0][1] - div.offsetHeight / 2) + 'px';
                            div.style.left = (points[0][0]) + 'px';
                        };
                        if (points != undefined) {
                            var timeS = ((animation.fade == true ? animation.time - 450 : animation.time - 100) / 1000) / 2;
                            var getAngle = function (x1, y1, x2, y2, bool) {
                                var x = x1 - x2;
                                var y = y1 - y2;
                                var z = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
                                var cos = y / z;
                                var radina = Math.acos(cos);
                                var angle = 180 / (Math.PI / radina);
                                if (x2 > x1 && y2 === y1) angle = 0;
                                if (x2 > x1 && y2 < y1) angle = angle - 90;
                                if (x2 === x1 && y1 > y2) angle = -90;
                                if (x2 < x1 && y2 < y1) angle = 270 - angle;
                                if (x2 < x1 && y2 === y1) angle = 180;
                                if (x2 < x1 && y2 > y1) angle = 270 - angle;
                                if (x2 === x1 && y2 > y1) angle = 90;
                                if (x2 > x1 && y2 > y1) angle = angle - 90;
                                if (bool == true && angle > 90) angle -= 180;
                                return angle;
                            };
                            var p1 = points[0];
                            var p2 = points[1];
                            var x0 = p1[0];
                            var y0 = p1[1];
                            var x1 = p2[0];
                            var y1 = p2[1];
                            div.style.transition = 'all 0s';
                            div.style.transform = 'rotate(' + getAngle(x0, y0, x1, y1, true) + 'deg)' + (x0 > x1 ? '' : ' rotateY(180deg)');
                            div.style['transform-origin'] = '0 50%';
                            var div2 = ui.create.div();
                            div2.style.zIndex = 1000;
                            div2.style['pointer-events'] = 'none';
                            div2.style.height = '20px';
                            div2.style.width = (Math.pow(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2), 0.5) + 2) + 'px';
                            div2.style.left = (x0) + 'px';
                            div2.style.top = (y0 - 10) + 'px';
                            div2.style.transform = 'rotate(' + getAngle(x0, y0, x1, y1) + 'deg) scaleX(0)';
                            div2.style['transform-origin'] = '0 50%';
                            div2.style.transition = 'all ' + (timeS * 4 / 3) + 's';
                            if (src != undefined && animation.image.indexOf('.') == -1) {
                                div2.style.backgroundSize = '100% 100%';
                                div2.style.opacity = '0.7';
                                div2.setBackgroundImage('extension/' + eName + '/pointer/' + animation.image + '/line.png');
                            } else {
                                div2.style.background = '#ffffff';
                            };
                            setTimeout(function () {
                                div.style.transition = 'all ' + (timeS * 4 / 3) + 's';
                                div.style.transform += ' translateX(' + (-(Math.pow(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2), 0.5) + 2)) + 'px)';
                                div2.style.transform = 'rotate(' + getAngle(x0, y0, x1, y1) + 'deg) scaleX(1)';
                            }, 50);
                            setTimeout(function () {
                                div2.style.transition = 'all ' + (timeS * 2 / 3) + 's';
                                div2.style.transform = 'rotate(' + getAngle(x0, y0, x1, y1) + 'deg) translateX(' +
                                    (Math.pow(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2), 0.5) + 2 -
                                        Math.pow(Math.pow(div.offsetHeight / 2, 2) + Math.pow(div.offsetWidth / 2, 2), 0.5)) + 'px) scaleX(0.01)';
                            }, 50 + timeS * 4 / 3 * 1000);
                            node.appendChild(div2);
                        };
                        if (animation.time <= 100000) {
                            if (animation.fade == true) {
                                if (div2 != undefined) {
                                    setTimeout(function () {
                                        div2.hide();
                                    }, animation.time - 350);
                                    setTimeout(function () {
                                        div.hide();
                                    }, animation.time - 400);
                                } else {
                                    setTimeout(function () {
                                        div.hide();
                                    }, animation.time - 350);
                                };
                            };
                            setTimeout(function () {
                                if (interval != undefined) clearInterval(interval);
                                if (timeoutID != undefined) clearTimeout(timeoutID);
                                if (animationID != undefined) cancelAnimationFrame(animationID);
                                if (fake == true) {
                                    ui.window.removeChild(div);
                                } else {
                                    if (node == undefined || node == false) {
                                        ui.window.removeChild(div);
                                    } else {
                                        node.removeChild(div);
                                    };
                                };
                                if (div2 != undefined) node.removeChild(div2);
                                _status.zhx_onAnimation--;
                                if (_status.zhx_onAnimationPause == true && _status.zhx_onAnimation == 0) {
                                    delete _status.zhx_onAnimationPause;
                                    game.resume2();
                                };
                            }, animation.time);
                        };
                    };
                    if (animation.delay != undefined) {
                        setTimeout(finish, animation.delay);
                    } else {
                        finish();
                    };
                };
                //原有方法备份
                game.zsOriginLineXy = game.linexy;
                //金龙指示线
                game.zsJinlongLineXy = function (path) {
                    var from = [path[0], path[1]];
                    var to = [path[2], path[3]];
                    if (game.chess) {
                        game.zsPlayLineAnimation('jinlonglinexy', ui.chess, false, [from, to]);
                    } else {
                        game.zsPlayLineAnimation('jinlonglinexy', ui.arena, false, [from, to]);
                    };
                };
                //覆盖原有方法
                game.linexy = game['zs' + config.lineShow + 'LineXy'];
                //定义style(不是很看得懂)
                {
                    var style = document.createElement('style');
                    style.innerHTML = "@keyframes fairy{"
                    for (var i = 1; i <= 20; i++) {
                        var rand1 = Math.floor(Math.random() * 255), rand2 = Math.floor(Math.random() * 255),
                            rand3 = Math.floor(Math.random() * 255), rand4 = Math.random();
                        style.innerHTML += i * 5 + '%{text-shadow: black 0 0 1px,rgba(' + rand1 + ', ' + rand2 + ', ' + rand3 + ', 0.6) 0 0 2px,rgba(' + rand1 + ', ' + rand2 + ', ' + rand3 + ', 0.6) 0 0 5px,rgba(' + rand1 + ', ' + rand2 + ', ' + rand3 + ', 0.6) 0 0 10px,rgba(' + rand1 + ', ' + rand2 + ', ' + rand3 + ', 0.6) 0 0 10px,rgba(' + rand1 + ', ' + rand2 + ', ' + rand3 + ', 0.6) 0 0 20px,rgba(' + rand1 + ', ' + rand2 + ', ' + rand3 + ', 0.6) 0 0 20px}';
                    }
                    style.innerHTML += "}";
                    document.head.appendChild(style);
                }
            }
            //------
            //
        }, help: {}, config: {
            gameEventLog: {
                name: '游戏事件日志',
                init: false,
                intro: '实时开关，当游戏事件创建时console.log(事件名)',
                onclick: (b) => {
                    game.saveConfig("extension_" + eName + "_gameEventLog", b);
                    lbqx?.gameEventLog(b);
                },
            },
            menuBeautification: {
                name: '菜单美化',
                init: true,
                intro: '开启全屏的菜单样式',
            },
            moreConfigNumber: {
                name: '更多武将数选项',
                init: true,
                intro: '为"选项-显示"中的"最近使用武将"与"最大武将数显示"提供更多数字选择',
            },
            AIxuanjiang: {
                name: 'AI选将',
                init: false,
                intro: '游戏开始时可以为AI或自己重新选将。(限身份场、斗地主、国战)',
            },
            groupShow: {
                name: "势力显示",
                init: false,
                intro: "武将名字上方显示势力字样"
            },
            phaseTip: {
                name: "阶段提示",
                init: true,
                intro: "如题，阶段提示"
            },
            lineShow: {
                name: '指示线特效',
                init: 'Jinlong',
                item: {
                    off: '关闭',
                    Jinlong: '金龙',
                },
                onclick: function (item) {
                    game.saveConfig('extension_' + eName + '_lineShow', item);
                    if (item == 'off')
                        game.linexy = game.zsOriginLineXy;
                    else
                        game.linexy = game['zs' + item + 'LineXy'];
                }
            },
            cardShow: {
                name: '卡牌特效',
                init: true,
                intro: '当 使用牌/装备触发/延时锦囊触发 时显示对应卡牌特效',
            },
            dynamicSkinShow: {
                name: '动皮特效',
                init: true,
                intro: '当拥有特效文件的武将使用【杀】时显示动皮特效',
            },
            damageShow: {
                name: '伤害特效',
                init: 'three',
                item: {
                    off: '关闭',
                    three: '随机',
                    dao: '刀',
                    jian: '剑',
                    fuzi: '斧',
                },
            },
            screenShow: {
                name: '全屏报幕',
                init: true,
                intro: '就那个[一破!卧龙出山]之类的',
            },
            shoushaMVP: {
                name: '手杀MVP',
                init: true,
                intro: '游戏结算后展示手杀MVP界面',
            },
            dontDelay: {
                name: '避免延时锦囊',
                init: true,
                intro: '你不能成为其他角色使用延时类锦囊的目标（类似陆抗【谦节】，但不影响给自己挂闪电等情况）',
            }
        }, package: {
            intro: "*本拓展代码并非全部由作者编写<br>*若功能失效请尝试关闭其他拓展或多次重启游戏<hr>",
            author: "凉拌清心",
            diskURL: "",
            forumURL: "",
            version: "4.0",
        }, files: { "character": [], "card": [], "skill": [], "audio": [] },
    }
});